<form id="addOrUpdateForm" lay-filter="addOrUpdateForm" class="layui-form model-form">

  <input name="id" type="hidden"/>

  <div class="layui-form-item" style="display: none">
    <label class="layui-form-label layui-form-required">教练名称</label>
    <div class="layui-input-block">
      <input name="coachname" class="layui-input" placeholder="请输入教练名称" lay-verType="tips" lay-verify="required" required/>
    </div>
  </div>


  <div class="layui-form-item">
    <label class="layui-form-label layui-form-required">评分</label>
    <div class="layui-input-block">
      <input name="score" class="layui-input" placeholder="请输入评分0-100" lay-verType="tips" lay-verify="required|score" required/>
    </div>
  </div>


  <div class="layui-form-item text-right">
    <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button>
    <button class="layui-btn" lay-filter="formSubmitBtn" lay-submit>保存</button>
  </div>
</form>

<script>
  layui.use(['layer', 'form', 'admin', 'xnUtil', 'xmSelect', 'laydate'], function () {
    var $ = layui.jquery;
    var layer = layui.layer;
    var form = layui.form;
    var admin = layui.admin;
    var xnUtil = layui.xnUtil;
    var xmSelect = layui.xmSelect;
    var laydate = layui.laydate;

    form.verify({
      //密码的验证
      score: function (value) {
        if(value>100||value<0){
          return "评分在 0 ~ 100 之间";
        }
      },
    });

    laydate.render({
      elem: '#maketimeId'
    });
    laydate.render({
      elem: '#paytimeId'
    });

    var editData = admin.getLayerData('#addOrUpdateForm').data;
    if(editData !== null && editData !== undefined) {
      form.val('addOrUpdateForm', editData);
    }

    /**
     * 表单提交事件
     */
    form.on('submit(formSubmitBtn)', function (data) {
      layer.load(2);

      var url = getProjectUrl() + 'order/score' ;
      data.field.state = data.field.score;
      admin.req(url, JSON.stringify(data.field), function(res){
        layer.msg(res.message, {icon: 1, time: 1000}, function () {
          admin.putLayerData('formOk', true, '#addOrUpdateForm');
          admin.closeDialog('#addOrUpdateForm');
        });
      }, 'post');
      return false;
    });
  });
</script>
</body>
</html>
